import 'package:flutter/material.dart';

import '../compant/Photos.dart';

class Search extends StatefulWidget {
  const Search({super.key});

  @override
  State<Search> createState() => _SearchState();
}

class _SearchState extends State<Search> {
  final FocusNode myFocusNode = FocusNode();
  bool isFocused = false;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    myFocusNode.addListener(_onFocusChange);
  }

  void _onFocusChange() {
    setState(() {
      isFocused = myFocusNode.hasFocus;
    });
  }

  @override
  void dispose() {
    // TODO: implement dispose
    myFocusNode.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        scrolledUnderElevation: 0,
        leadingWidth: 140,
        leading: Container(
          padding: const EdgeInsets.only(left: 30, top: 20),
          child: const Text(
            'Search',
            style: TextStyle(fontSize: 28),
          ),
        ),
        actions: [
          Image.asset('assets/icon17.png'),
          const Padding(padding: EdgeInsets.all(15)),
        ],
      ),
      body: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 30),
        child: SingleChildScrollView(
          child: Column(
            children: [
              Container(
                height: 60,
                padding: EdgeInsets.symmetric(horizontal: 20),
                decoration: BoxDecoration(
                    color: Colors.white,
                    boxShadow: [
                      BoxShadow(
                          color: Colors.black.withOpacity(0.05),
                          blurRadius: 27,
                          offset: const Offset(0, 13))
                    ],
                    borderRadius: BorderRadius.circular(10)),
                child: Row(children: [
                  Expanded(
                    child: TextField(
                      focusNode: myFocusNode,
                      decoration: InputDecoration(
                        border: InputBorder.none,
                        hintText: "Type here to Search",
                        hintStyle: TextStyle(
                          color: Color(0xffDBDBDB),
                        ),
                        // suffix: Image.asset('assets/appbardelete.png'),
                      ),
                    ),
                  ),
                  isFocused
                      ? Image.asset('assets/appbardelete.png')
                      : Image.asset('assets/botton2.png'),
                ]),
              ),
              SizedBox(
                height: 20,
              ),
              const Photos(),
              const Row(
                children: [
                  Expanded(
                    flex: 2,
                    child: Photos(),
                  ),
                  SizedBox(
                    width: 20,
                  ),
                  Expanded(
                    flex: 1,
                    child: Photos(),
                  ),
                ],
              ),
              const Row(
                children: [
                  Expanded(
                    flex: 1,
                    child: Photos(),
                  ),
                  SizedBox(
                    width: 20,
                  ),
                  Expanded(
                    flex: 2,
                    child: Photos(),
                  ),
                ],
              ),
              const Row(
                children: [
                  Expanded(
                    flex: 1,
                    child: Photos(),
                  ),
                  SizedBox(
                    width: 20,
                  ),
                  Expanded(
                    flex: 1,
                    child: Photos(),
                  ),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}
